
package com.ffcs.crmd.tsp.admin.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.JobIdentityInfoDTO;
import com.ffcs.crmd.tsp.admin.api.facade.IJobIdentityInfoFacade;
import com.ffcs.crmd.tsp.admin.entity.JobIdentityInfo;
import com.ffcs.crmd.tsp.admin.service.IJobIdentityInfoService;

@Service("jobIdentityInfoFacade")
public class JobIdentityInfoFacadeImpl extends AbstractCrmDomFacade implements IJobIdentityInfoFacade {
   	
   	@Autowired
	private IJobIdentityInfoService jobIdentityInfoService;
	   
   	
   	private PageInfo<JobIdentityInfoDTO> copyPageInfo(PageInfo<JobIdentityInfo> pageInfo) throws Exception{
        PageInfo<JobIdentityInfoDTO> pageInfoDto = new PageInfo<JobIdentityInfoDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), JobIdentityInfoDTO.class));
        return pageInfoDto;
    }
   	
   	
	@Override
    public JobIdentityInfoDTO get(JobIdentityInfoDTO jobIdentityInfoDTO) throws Exception {
       	 JobIdentityInfo jobIdentityInfo = new JobIdentityInfo();
         BeanUtils.applyIf(jobIdentityInfo, jobIdentityInfoDTO, false);
     
        JobIdentityInfo rjobIdentityInfo = jobIdentityInfoService.get(jobIdentityInfo);
        JobIdentityInfoDTO rjobIdentityInfoDTO = new JobIdentityInfoDTO();
        BeanUtils.applyIf(rjobIdentityInfoDTO, rjobIdentityInfo, false);
        return rjobIdentityInfoDTO;
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param identity
     * @param jobId
     * @return
     * @throws Exception
     */
    @Override
    public List<JobIdentityInfoDTO> query(JobIdentityInfoDTO jobIdentityInfoDTO) throws Exception {
        JobIdentityInfo jobIdentityInfo = new JobIdentityInfo();
        BeanUtils.applyIf(jobIdentityInfo, jobIdentityInfoDTO, false);
        
        List<JobIdentityInfo> jobIdentityInfoList = jobIdentityInfoService.query(jobIdentityInfo);
        return BeanUtils.copyList(jobIdentityInfoList, JobIdentityInfoDTO.class);
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param identity
     * @param jobId
     * @param pageNumber
     * @param pageSize
     * @return
     * @throws Exception
     */
    @Override
    public PageInfo<JobIdentityInfoDTO> queryPage(JobIdentityInfoDTO jobIdentityInfoDTO) throws Exception {
        JobIdentityInfo jobIdentityInfo = new JobIdentityInfo();
        BeanUtils.applyIf(jobIdentityInfo, jobIdentityInfoDTO, false);
        
        PageInfo<JobIdentityInfo> pageInfo = jobIdentityInfoService.queryPage(jobIdentityInfo, jobIdentityInfoDTO.getPageNumber(), jobIdentityInfoDTO.getPageSize());
        return copyPageInfo(pageInfo);
    }
    
    @Override
    public void remove(JobIdentityInfoDTO jobIdentityInfoDTO) throws Exception {
        JobIdentityInfo jobIdentityInfo = new JobIdentityInfo();
        BeanUtils.applyIf(jobIdentityInfo, jobIdentityInfoDTO, false);
        jobIdentityInfoService.deleteJobIdentityInfo(jobIdentityInfo);
    }


    @Override
    public void remove(List<JobIdentityInfoDTO> jobIdentityInfoDTOList) throws Exception {
        List<JobIdentityInfo> jobIdentityInfoList = BeanUtils.copyList(jobIdentityInfoDTOList, JobIdentityInfo.class);
        jobIdentityInfoService.deleteJobIdentityInfo(jobIdentityInfoList);
    }

    @Override
    public void save(List<JobIdentityInfoDTO> taskRegisterInfoDtoList) throws Exception {
        List<JobIdentityInfo> jobIdentityInfoList = BeanUtils.copyList(taskRegisterInfoDtoList, JobIdentityInfo.class);
        jobIdentityInfoService.saveJobIdentityInfo(jobIdentityInfoList);
    }
    
    @Override
    public void save(JobIdentityInfoDTO taskRegisterInfoDto) throws Exception {
        JobIdentityInfo jobIdentityInfo = new JobIdentityInfo();
        BeanUtils.applyIf(jobIdentityInfo, taskRegisterInfoDto, false);
        jobIdentityInfoService.saveJobIdentityInfo(jobIdentityInfo);
    }
}
